﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WHW_NetUtility
{
    class ListViewOpe
    {

        public static bool RowColor(ListView lv, System.Drawing.Color oddcolor,System.Drawing.Color evencolor)
        {

            return true;
        }
        /// <summary>
        /// 按行添加listview数据(添加到尾部)
        /// </summary>
        /// <param name="lv">listview控件名称</param>
        /// <param name="context">要添加到listview控件中的行数据数组，不添加内容的列，字符串为空</param>
        /// <returns>添加成功返回true，否则返回false</returns>
        public static bool Add(ListView lv, string[] context)
        {
            try
            {
                lv.BeginUpdate();
                int count = lv.Items.Count;
                lv.Items.Add((count + 1).ToString());
                for (int i=0;i<context.Length;i++)
                {
                    lv.Items[count].SubItems.Add(context[i]);
                }
                lv.EndUpdate();
                return true;
            }
            catch (System.Exception ex)
            {
                Log4Helper.WriteLog("ListViewOpe.Add", ex);
                return false;
            }
        }
    }
}
